package com.fenghongzhang.login;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class MySqlHelper extends SQLiteOpenHelper {

    public MySqlHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("create table user(id integer primary key autoincrement,username varchar(100),pwd varchar(100))");

//        //事务
//        db.beginTransaction();
//        //代码
//        ContentValues contentValues = new ContentValues();
//        contentValues.put("username","12313123");
//        contentValues.put("pwd","1231231231313211312");
//        db.insert("user",null,contentValues);
//        db.setTransactionSuccessful();
//        db.endTransaction();
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
